/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.isd.global.dao;

import javax.ejb.Stateless;
import javax.ejb.LocalBean;


/**
 *
 * @author ctrosch
 */
@Stateless
@LocalBean
public class ComprobanteDAO extends BaseDAO {

    public Integer getNumeroComprobante(String modfor,String codfor){

        try {
            em.flush();
            String query = "SELECT (Max(FCRMVH_NROFOR) + 1 )"
                    + "FROM TVRMVH "
                    + "WHERE FCRMVH_MODFOR = '" + modfor + "' "
                    + "AND FCRMVH_CODFOR = '" + codfor + "'";

            Integer proxNumero = (Integer) getEntityManager().createNativeQuery(query).getSingleResult();

            if(proxNumero==null) return 1;
            else return proxNumero;
        } catch (Exception e) {
            return 1;
        }
    }

    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

//    public Comprobante getComprobante(ComprobantePK idPK){
//
//        return getObjeto(Comprobante.class, idPK);
//    }

 
}
